package com.toggery.POS.service;

import com.toggery.POS.dao.RoleMapper;
import com.toggery.POS.entity.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleService {
    @Autowired
    RoleMapper mapper;

    public List<Role> findAll(){
        return  mapper.findAll();
    }

    public boolean save(Role role){
        if(mapper.selectByPrimaryKey(role.getId())==null){
            mapper.insert(role);
            return true;
        }else {
            return false;
        }
    }

    public boolean updateRole(Role role){
        if(mapper.updateByPrimaryKey(role)>0){
            return true;
        }else {
            return false;
        }
    }
    public boolean deleteByid(int id){
        if(mapper.deleteByPrimaryKey(id)>0){
            return true;
        }else {
            return false;
        }
    }
    public Role findById(int id){
        return mapper.selectByPrimaryKey(id);
    }


//    public List<Role> findAllWithin() {
//        return mapper.findAll();
//    }
}
